package com.kaizeli.website.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kaizeli.website.pojo.entity.AttendanceDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * 考勤Mapper接口
 */
@Mapper
public interface AttendanceMapper extends BaseMapper<AttendanceDO> {
    
    /**
     * 分页查询考勤记录
     */
    Page<AttendanceDO> pageQuery(Page<AttendanceDO> page, 
                                  @Param("employeeId") Long employeeId,
                                  @Param("projectId") Long projectId,
                                  @Param("startDate") LocalDate startDate,
                                  @Param("endDate") LocalDate endDate,
                                  @Param("status") String status);
    
    /**
     * 根据员工ID和日期范围查询考勤
     */
    List<AttendanceDO> selectByEmployeeAndDateRange(@Param("employeeId") Long employeeId,
                                                     @Param("startDate") LocalDate startDate,
                                                     @Param("endDate") LocalDate endDate);
    
    /**
     * 根据项目ID和日期范围查询考勤
     */
    List<AttendanceDO> selectByProjectAndDateRange(@Param("projectId") Long projectId,
                                                    @Param("startDate") LocalDate startDate,
                                                    @Param("endDate") LocalDate endDate);
    
    /**
     * 统计员工工作时长
     */
    Double sumWorkHoursByEmployee(@Param("employeeId") Long employeeId,
                                   @Param("startDate") LocalDate startDate,
                                   @Param("endDate") LocalDate endDate);
}

